package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.ScenicDetail;
import cn.wolfcode.luowowo.article.mapper.ScenicDetailMapper;
import cn.wolfcode.luowowo.article.query.ScenicQuery;
import cn.wolfcode.luowowo.article.service.IScenicDetailService;
import cn.wolfcode.luowowo.article.service.IScenicService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ScenicDetailServiceImpl implements IScenicDetailService {

    @Autowired
    private ScenicDetailMapper scenicDetailMapper;

    @Override
    public List<ScenicDetail> getTop5(Long destId) {
        return scenicDetailMapper.getTop5(destId);
    }

    @Override
    public List<ScenicDetail> getHotTop10(Long destId) {
        return scenicDetailMapper.getHotTop10(destId);
    }

    @Override
    public PageInfo<ScenicDetail> getAll(ScenicQuery qo) {
        qo.setPageSize(5);
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<ScenicDetail> list = scenicDetailMapper.getAll(qo);
        return new PageInfo<>(list);
    }

    @Override
    public ScenicDetail get(ScenicQuery qo) {
        return scenicDetailMapper.get(qo);
    }
}
